from django.shortcuts import render
# Create your views here.
from rest_framework.generics import ListAPIView
from . import models
from .serializers import BannerModelSerializer,NavModelSerializer
from luffyapi.settings import constants

class BannerListAPIView(ListAPIView): # ⾃动导包
    queryset = models.Banner.objects.filter(is_show=True,is_deleted=False).order_by("-orders","-id")[:constants.BANNER_LENGTH]
    # 没有必要获取所有图⽚数据，因为有些可能是删除了的、或者不显示的切⽚获取数据的时候，我们可以将切⽚⻓度设置成配置项
    serializer_class = BannerModelSerializer

    # print(serializer_class)

class NavListAPIView(ListAPIView):
    queryset = models.Nav.objects.filter(is_show=True,is_deleted=False,position=1).order_by("-orders","-id")[:constants.HEADER_NAV_LENGTH]
    serializer_class = NavModelSerializer
